<?php

include('includes/connect.php');

$now=mktime();
$sql = "SELECT * FROM product WHERE begindate <= '".$now."' AND enddate >= '".$now."' ORDER BY RAND() LIMIT 3";
$result = mysql_query($sql);

while ($row = mysql_fetch_array($result)) {
$id=$row['productid'];
$naam=$row['productnaam'];
$cat=$row['categorie'];

if($id<='166526')
{
  $img='productimages/'.$id.'.jpg';
}
else
{
  $img=$row['img'];
}

if ($row['begindate'] < $now && $row['enddate'] > $now )
{
    $price=$row['Promotieprijs'];
}
else
{
    $price=$row['stdprijs'];
}

echo    "<center><table border='0'><tr><td>".
        "<a href=\"product.php?id=$id \" title=\"$naam\"><img src=\"img/$img\" width=\"120\" height=\"120\"></a>".
        "</td></tr></table>Slechts <b>&euro;".number_format($price,2)." !</b></center>";
}

?>